import Cookies from 'js-cookie'

const state = {
    currentPath: Cookies.get('currentPath'),
    currentHeader: Cookies.get('currentHeader'),
    isConsole: Cookies.get('isConsole'),
}

const mutations = {
    SET_CURRENTPATH: (state, path) =>{
        state.currentPath = path;
        Cookies.set('currentPath',path)
    },
    SET_CURRENTHEADER: (state, header) =>{
        state.currentHeader = header;
        Cookies.set('currentHeader',header)
    },
    SET_ISCONSOLE: (state, flag) =>{
            state.isConsole = flag; 
        Cookies.set('isConsole',flag)
    }
}

const actions = {
    setCurrentPath({ commit }, path){
        commit('SET_CURRENTPATH', path)
    },
    setCurrentHeader({ commit }, header){
        commit('SET_CURRENTHEADER', header)
    },
    setIsConsole({ commit }, flag){
        commit('SET_ISCONSOLE',flag)
    }
}

export default {
    namespaced: true,
    state,
    mutations,
    actions
}